﻿//-----------------------------------------------------------------------
// <copyright file="SmartManipulator.Toggle.cs" company="Nathan Miller">
// Copyright (c) Nathan Miller.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// </copyright>
//-----------------------------------------------------------------------
namespace TileTool.Base.Manipulator.Smart
{
    using TileTool.Common.Math;
    using TileTool.Editor.Tool.Scene;

    /// <summary>
    /// Toggle implementation of the smart manipulator.
    /// </summary>
    public partial class SmartManipulator
    {
        #region Methods - Private

        /// <summary>
        /// Setup rotate handles.
        /// </summary>
        private void Toggle_SetupHandles()
        {
            SmartManipulatorHandle handle = new SmartManipulatorHandle();

            handle.Id = (int)SmartManipulatorHandlePosition.SizeTranslateToggle;
            handle.Size = new Size2D(this.settings.RotateCircleRadius);
            handle.IdleColor = this.settings.TranslateToggleColor;
            handle.SelectedColor = this.settings.TranslateToggleSelectedColor;
            handle.Ellipse = false;

            this.AddManipulatorHandle(handle);
        }

        /// <summary>
        /// Called when the manipulator is reset.
        /// </summary>
        private void Toggle_Reset()
        {
        }

        /// <summary>
        /// Update the rotation handle positions.
        /// </summary>
        private void Toggle_UpdateHandlePositions()
        {
            Rect2D rect = new Rect2D(Vector2D.Zero, this.Size);
            Vector2D[] rectPoints = rect.GetPoints();
            Vector2D offset = Vector2D.AxisY * this.settings.TranslateToggleCircleOffset;

            this.PositionHandle(SmartManipulatorHandlePosition.SizeTranslateToggle, ((rectPoints[0] + rectPoints[1]) * 0.5f) - offset);
        }

        /// <summary>
        /// Called when a drag begins.
        /// </summary>
        /// <param name="sceneInputData">Scene input data.</param>
        /// <param name="canvasPos">Canvas position position where the drag started.</param>
        private void Toggle_DragBegin(SceneToolInputData sceneInputData, Vector2D canvasPos)
        {
        }

        /// <summary>
        /// Called when a drag ends.
        /// </summary>
        private void Toggle_DragEnd()
        {
            this.ToggleSizeMode();
        }

        /// <summary>
        /// Called when a drag update happens on any handle.
        /// </summary>
        /// <param name="sceneInputData">Scene input data.</param>
        /// <param name="canvasPos">Canvas position position where the mouse is currently.</param>
        private void Toggle_DragUpdate(SceneToolInputData sceneInputData, Vector2D canvasPos)
        {
        }

        #endregion
    }
}